package day24;

import java.io.*;
import java.util.Arrays;

public class Demo {
    public static void main(String[] args) throws IOException {
        //创建缓冲输入流，借助于字节输入流
        FileInputStream fis=new FileInputStream("C:\\Users\\梅穿内裤\\Desktop\\IOTest\\aa\\my.txt");
        BufferedInputStream  bis=new BufferedInputStream(fis);
        int c=bis.read();
        System.out.println(c);
        c=bis.read();
        System.out.println(c);
        byte[] bs=new byte[10];
        bis.read(bs);
        System.out.println(Arrays.toString(bs));

        //缓冲输出流
        FileOutputStream fos=new FileOutputStream("C:\\Users\\梅穿内裤\\Desktop\\IOTest\\aa\\dd\\my.txt");
        BufferedOutputStream bos=new BufferedOutputStream(fos);
        //由于缓冲流在缓冲区保存的，如果没有清空缓存，数据不会到本地磁盘
        bos.write(97);
        bos.write(98);
        bos.write("你好".getBytes());
        bos.flush(); //清空缓存
//        bos.close();

    }
}
